<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./newTemplate.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="top"/>

    <ui:define name="left">
        <ui:include src="/inc/menu.xhtml"/>
    </ui:define>

    <ui:define name="content">
        
        <h:form id="form">
            <p:growl id="growl" showDetail="true"/>  
            <p:panel header="Новости">
                <p:dataTable id="news" var="news" value="#{newsAction.newsFilter}" rowKey="#{news.id}" rows="15"
                             selection="#{newsAction.selectedNews}" selectionMode="single" paginator="true">
                    
                    <p:ajax event="rowSelect" update=":form:news_detail" oncomplete="news_detail.show()" /> 
                    
                    <p:column headerText="Дата" id="date">  
                        <h:outputText value="#{news.date}">
                            <f:convertDateTime pattern="dd.MM.yyyy" />
                        </h:outputText>  
                    </p:column>
                    <p:column headerText="Рубрика" id="rubric">  
                        #{news.rubric}  
                    </p:column>
                    <p:column headerText="Тема" id="header">  
                        #{news.header}  
                    </p:column>
                </p:dataTable>
            </p:panel>
            <p:dialog id="news_detail" header="#{newsAction.selectedNews.header}" resizable="false" 
                      widgetVar="news_detail" modal="true" closeOnEscape="true"
                      showEffect="fade" hideEffect="fade" height="600px" width="1000px">
                <p:scrollPanel style="padding:  10px; border: none !important;">
                        <h:outputText value="#{newsAction.selectedNews.text}" escape="false"/>
                </p:scrollPanel>
            </p:dialog>
            
        </h:form>
    </ui:define>
    
    <ui:define name="right">
        <p:panel header="Меню новостей">
            <h:form>
                <p:calendar id="date_s" value="#{newsAction.filterDateS}">
                    
                    <p:ajax event="dateSelect" listener="#{newsAction.filter}" update=":form:news :form:growl" />
                </p:calendar>
                
                <p:calendar id="date_po">
                    <f:convertDateTime pattern="dd/MM/yyyy" />
                </p:calendar>
                
                <p:selectCheckboxMenu value="#{newsAction.selectedRubrics}" filter="true" label="Рубрика" styleClass="rubricsMenu">
                    <f:selectItems value="#{newsAction.rubrics}"/>
                </p:selectCheckboxMenu>                
            </h:form>
        </p:panel>
    </ui:define>

</ui:composition>
